package com.zenchn.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/***
 * 城乡分类代码 枚举
 * @author dingxinfa
 * @date 2018-08-22
 */
public enum  TownRuralCategoryCodeEnum {
    /** 主城区 **/
    CATEGORY_111("111","主城区"),
    /** 城乡结合区 **/
    CATEGORY_112("112","城乡结合区"),
    /** 镇中心区 **/
    CATEGORY_121("121","镇中心区"),
    /** 镇乡结合区 **/
    CATEGORY_122("122","镇乡结合区"),
    /** 特殊区域 **/
    CATEGORY_123("123","特殊区域"),
    /** 乡中心区 **/
    CATEGORY_210("210","乡中心区"),
    /** 村庄 **/
    CATEGORY_220("220","村庄");


    /**id**/
    private String code;
    /**中文描述**/
    private String desc;

    TownRuralCategoryCodeEnum(String code, String desc){
        this.code = code;
        this.desc = desc;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    /**
     * 获取 枚举值列表
     */
    public static List<Map<String,String>> getList() {
        List<Map<String,String>> valueList=new ArrayList<>();
        for (TownRuralCategoryCodeEnum categoryCode : values()) {
            Map<String,String> code=new HashMap<>(2);
            code.put("code",categoryCode.getCode());
            code.put("desc",categoryCode.getDesc());
            valueList.add(code);
        }
        return valueList;
    }

    public static String getDesc(String code){
        for (TownRuralCategoryCodeEnum e : values()) {
            String currCode=e.getCode();
            if(currCode.equals(code)){
                return e.getDesc();
            }
        }
        return "";
    }
}
